package model

import (
	"gorm.io/gorm"
	"time"
)

type CustInfo struct {
	Id        int64     `json:"id"`
	CustId    string    `json:"custId"`
	Mobile    string    `json:"mobile"`
	RealName  string    `json:"realName"`
	Province  string    `json:"province"`
	City      string    `json:"city"`
	Address   string    `json:"address"`
	LoginIp   string    `json:"loginIp"`
	LoginTime time.Time `json:"loginTime"`
	Enabled   uint64    `json:"enable"`
	VipLevel  uint64    `json:"vipLevel"`
}

// get custId from mobile
func GetCustIdFromMobile(tx *gorm.DB, custInfo *CustInfo) error {
	result := tx.Model(custInfo).First(custInfo)
	if result.Error != nil {
		return result.Error
	}
	return nil
}

func GetUserInfo(info *CustInfo) error {
	DB.Model(&CustInfo{}).First(info)
	return nil
}
